<HTML>
<HEAD>
<TITLE>MSVidCtl: ATSC Digital TV</TITLE>
</HEAD>

<!--
	This sample requires a ATSC digital TV tuner card that is compatible with the Microsoft TV Technologies 
		driver architecture (BDA - Broadcast Driver Architecture).  

	You must also have a MPEG-2 decoder installed that is capable of decoding the resolution 
		(e.g. 480p or 1080i) of the digital broadcast.  
	
	High definition (HDTV) broadcasts may be at a resolution greater than your video card or MPEG-2 deocoder 
		are capable of operating.
-->

<BODY BGCOLOR="#000001" TEXT="#FFFFFF" LINK="#FCCB7A" VLINK="#551A8B" ALINK="#EE0000">

<CENTER>

<P>
<INPUT id=startbutton type=button value="Power On">
<INPUT id=stopbutton type=button value="Power Off">
</P>

<OBJECT ID="MSVidCtl" CLASSID="CLSID:B0EDF163-910A-11D2-B632-00C04F79498E"></OBJECT>

</CENTER>


<P ALIGN="center">
	<BR>
	<B>Channel: </B> <INPUT TYPE="text" id=currentchannel maxlength=3 SIZE=3>
	<B>Minor Chanel: </B> <INPUT TYPE="text" id=currentminorchannel maxlength=3 SIZE=3>
	<INPUT id=enter type=button value="Enter">
	<br>
	<INPUT id=chanup type=button value="Channel Up">
	<INPUT id=chandown type=button value="Channel Down">
	<BR>
	</P>
<CENTER>

<P id=dl>xxx</P>

<SCRIPT language=vbscript>
option explicit

dim tscontainer 'tuning space collection
dim ts 'ATSC tuning space 
dim tr 'ATSC tune request
dim locator 'ATSC Locator

sub window_onload
	
	MSVidCtl.MaintainAspectRatio = True
	MSVidCtl.Width = 640
	MSVidCtl.Height = 480

	set tscontainer = createobject("BDATuner.SystemTuningSpaces")	

	'Get the tuning space with the word "ATSC" in its name.  
	'This tuning space works with North American ATSC terrestrial broadcast
	'For other types of digital broadcast, you may need to create your own tuning space
	set ts = tscontainer("ATSC")
        
	set tr = ts.CreateTuneRequest
        
	'By default we will start on channel 46
	'The physical channel property on the locator sets the 'actual' physical channel
	'The Microsoft TV Technology Network Provider will fill in the channel and minor channel, if available
	set locator = CreateObject("BDATuner.ATSCLocator")
	locator.PhysicalChannel = 46
	tr.locator = locator
	tr.MinorChannel = -1
	tr.Channel = -1
      
        'Pass the tune request to the View() method and then build the graph
	MSVidCtl.View tr
	MSVidCtl.Run
	
	dl.innertext = MSVidCtl.InputActive.Tune.Channel
	currentchannel.value = MSVidCtl.InputActive.Tune.Locator.PhysicalChannel
	currentminorchannel.value = MSVidCtl.InputActive.Tune.MinorChannel
end sub

sub startbutton_onclick
	'This starts the graph and begins displaying audio and video
        MSVidCtl.Run
end sub

sub stopbutton_onclick
	'This stops the graph, but does not destroy it
        MSVidCtl.Stop
end sub

sub chanup_onclick
        'Tune to the next channel up
	locator.PhysicalChannel = locator.PhysicalChannel+1
	tr.Locator = locator
	tr.Channel = -1
	tr.MinorChannel = -1
        MSVidCtl.View tr

        dl.innertext = MSVidCtl.InputActive.Tune.Channel
	currentchannel.value = MSVidCtl.InputActive.Tune.Locator.PhysicalChannel
	currentminorchannel.value = MSVidCtl.InputActive.Tune.MinorChannel
end sub

sub chandown_onclick
        'Tune to the next channel up
	locator.PhysicalChannel = locator.PhysicalChannel-1
	tr.Locator = locator
	tr.Channel = -1
	tr.MinorChannel = -1
        MSVidCtl.View tr

        dl.innertext = MSVidCtl.InputActive.Tune.Channel
	currentchannel.value = MSVidCtl.InputActive.Tune.Locator.PhysicalChannel
	currentminorchannel.value = MSVidCtl.InputActive.Tune.MinorChannel
end sub

sub enter_onclick
	'Tune to the channel the user entered in the textbox
	'We allow the user to change to different virtual channels (minor channels)
	locator.PhysicalChannel = currentchannel.value
	tr.locator = locator
	tr.Channel = -1
	tr.MinorChannel = currentminorchannel.value
        MSVidCtl.View tr
        
	dl.innertext = MSVidCtl.InputActive.Tune.Channel
	currentchannel.value = MSVidCtl.InputActive.Tune.Locator.PhysicalChannel
	currentminorchannel.value = MSVidCtl.InputActive.Tune.MinorChannel
end sub

</Script>

</BODY>
</HTML>
